<template>
    <div>
<!-- Form -->
<el-button plain type="primary" @click="dialogFormVisible = true">新增放映厅</el-button>

<el-dialog title="新增放映厅" :visible.sync="dialogFormVisible">
  <el-form :model="form" style="width:80%">
    <el-form-item label="放映厅名称" label-width="130px">
      <el-input v-model="form.room_name" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="放映厅类型" label-width="130px">
      <el-select v-model="form.room_type" placeholder="请选择放映厅类型">
        <el-option
        v-for="item in types"
        :key="item.id"
        :label="item.type_name" :value="item.type_name"
        ></el-option>
      </el-select>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisible = false">取 消</el-button>
    <el-button type="primary" @click="submit">确 定</el-button>
  </div>
</el-dialog>

         <el-divider content-position="left">放映厅列表</el-divider>
         <el-table :data='rooms'>
            <el-table-column prop="room_name" label="放映厅名称" align=" center"></el-table-column>
            <el-table-column prop="room_type" label="放映厅类型" align=" center"></el-table-column>
            <el-table-column label="放映厅座位数" align=" center">
                <template slot-scope="scope">
                    {{scope.row.room_size ? scope.row.room_size: "[暂无]" }}
                </template>
            </el-table-column>
            <el-table-column label="操作" align=" center">
            <template slot-scope="scope">
          <el-button
           @click="$router.push('/home/showingon-plan-list/'+scope.row.id)"
           type="success" icon="el-icon-check" circle></el-button>
          <el-button
          @click="$router.push('/home/showingon-plan-add/'+scope.row.id)"
           type="info" icon="el-icon-message" circle>
          </el-button>
         <el-button
            @click="$router.push('/home/seat-template/'+scope.row.id)"
            size="small" type="warning" icon="el-icon-menu" circle></el-button>
          <el-button
           type="danger"
            icon="el-icon-delete" circle>
          </el-button>
          </template>
            </el-table-column>
         </el-table>
    </div>
</template>

<script>
import httpApi from '@/http'
    export default {
        data() {
            return {
        dialogFormVisible: false,
        types:[],
        rooms:[],
        form: {
          room_name: '',
          room_type: '',
          movie_cinema_id:this.$route.params.cinemaId,

        },
            }
        },
       methods: {

        submit(){
            console.log(this.form)
            httpApi.cinemaRoomApi.add(this.form).then(res=>{
                console.log('新增放映厅',res)
                if(res.data.code==200){
                    this.$message.success('放映厅添加ok')
                    this.dialogFormVisible = false
                }else{
                    this.$message.error('系统异常，添加失败')
                }
            })
                
        },

        initRoomType() {
            httpApi.cinemaRoomApi.queryAllTypes().then(res=>{
                console.log('加载电影厅类型列表',res)
                this.types=res.data.data
            })
            httpApi.cinemaRoomApi.list({cinema_id:this.form.movie_cinema_id}).then(res=>{
                console.log('加载电影厅数据',res)
                this.rooms=res.data.data
            })
        }
       },
        mounted(){
            // 初始化电影类型
            this.initRoomType()
        }
    }
</script>

<style lang="scss" scoped>

</style>